<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php

/*echo " <script type='text/javascript'> lim=prompt('no.') </script>";
	$lim=$_POST['lim'];
 to input value from .js to php
 */
if(isset($_POST['submit']))
{
	$x0=$_POST['x0'];
	$a=$_POST['a'];
	$c=$_POST['c'];
	$m=$_POST['m'];
	$lim=$_POST['lim'];
	
	//echo $lim;
	$rand=$x0;
	$FILE=fopen('oput.txt','w+');
	for($i=0;$i<$lim;$i++)
	{
		$rand=($a*$rand+$c)%$m;// linear congruency generator code
		
		//echo $rand;
		fwrite($FILE,$rand.PHP_EOL);
	}
	fclose($FILE);
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>random number gen</title>
<!--<script type="text/javascript">
    function lim() {
        var lim = document.getElementByName('lim');
        lim.value = prompt("Please enter the number of random numbers");
    	return lim;
	}
</script>
--></head>

<body>
<h1><center/>linear congruency generator</h1>
<form method="post">
<label> x0&nbsp;</label> <input type="number" name="x0" /><br/><hr/>
<label> a&nbsp;&nbsp;</label><input type="number" name="a" /><br/><hr/>
<label> c&nbsp;&nbsp;</label><input type="number" name="c" /><br/><hr/>
<label> m&nbsp;&nbsp;</label><input type="number" name="m" /><br/><hr/>
<label> total number of random numbers needed&nbsp;&nbsp;</label><input type="number" name="lim" /><br/><hr/>

<input type="submit" name="submit" value="submit" />
<p style="margin-top:400px"><center/>http://www.slideshare.net/kishoj/random-number-generation-11302708</p>

<p style=""><center/>&copy Ashwin</p>

</form>
</body>
</html>